<template>
	<view class="page">
		<cell title="手机" :value="userinfo.mobile" border-bottom></cell>
		<cell title="登录密码" border-bottom></cell>
		<cell title="姓名" :value="userinfo.username" border-bottom :rightIcon="false"></cell>
		<cell title="头像"  border-bottom :rightIcon="false"></cell>
		<cell title="公司注册" border-bottom></cell>
		<cell title="初始化" border-bottom></cell>
		<view class="exit-button" @click="exitAccount">退出</view>
	</view>
</template>

<script>
	import cell from '../component/cell/cell.vue';
	import * as api from '@/utils/api.js';
	export default {
		components:{
			cell
		},
		data() {
			return {
				userinfo:getApp().globalData.userInfo
			}
		},
		methods: {
			exitAccount:function(){
					uni.showModal({
						title: '',
						content: '是否确认退出登录？',
						success: function (res) {
							if (res.confirm) {
								uni.showToast({
									title: '退出成功',
									duration: 2000,
									complete() {
										api.logout().then(res=>{
											uni.clearStorageSync();
											getApp().globalData.userInfo = {};
											uni.reLaunch({
												url: '/pages/index/index'
											});
										})
									}
								});
							}
						}
					});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		background-color: #f6f6f6;
		min-height: 100vh;
		.exit-button{
			width: calc(100% - 40rpx);
			color:white;
			text-align: center;
			line-height:80rpx;
			margin: 0 auto;
			margin-top:40rpx;
			border-radius: 10rpx;
			background-color: #4269e2;
		}
	}
</style>
